﻿using System;
using BizUnit;
using BTS.Testing.TraceMonitor.BizUnit4.TestSteps.Helpers;

namespace BTS.Testing.TraceMonitor.BizUnit4.TestSteps
{
    /// <summary>
    /// Polls the list of all events to look for one which matches criteria
    /// </summary>
    public class PollForEvent : BizUnit.Xaml.TestStepBase
    {
        public string RegEx { get; set; }
        public bool IncludeBodyCompare { get; set; }
        public int TimeoutSeconds { get; set; }
        public bool DeleteAfterFound { get; set; }
        public string QueuePath { get; set; }


        public override void Execute(Context context)
        {
            bool found = EventTraceManager.PeekForAnyEvent(RegEx, IncludeBodyCompare, TimeoutSeconds, DeleteAfterFound, QueuePath);
            if (!found)
                throw new ApplicationException("The event has not been found");
        }

        public override void Validate(Context context)
        {
            
        }
    }
}
